package com.lavender.transaction.transaction.impl;

import com.lavender.transaction.entity.Account;
import com.lavender.transaction.service.AccountService;
import com.lavender.transaction.transaction.AccountServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AccountServiceInterfaceImpl implements AccountServiceInterface {

    @Autowired
    private AccountService accountService;

    @Transactional(propagation = Propagation.NESTED)
    @Override
    public String insert() {
        insertAccount();
        return "ok";
    }

    private void insertAccount() {
        Account account = new Account();
        account.setUserId("admin");
        account.setAccountNum("gs123456");
        account.setMoney(10000);
        accountService.insert(account);
    }

}
